package net.dasviertel.buddylockscreen.application;

import com.monitorcontactschanges.R;

import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class AppPreferences {

	private SharedPreferences sharedPreferences;

	private static AppPreferences instance;

	private static final String CONTACT_ID = "CONTACT_ID";
	private static final String CONTACT_NAME = "CONTACT_NAME";
	private static final String CONTACT_PHONE_NUMBER = "CONTACT_PHONE_NUMBER";
	private static final String CONTACT_PHONE_NUMBER_NAME_XPOS = "CONTACT_PHONE_NUMBER_NAME_XPOS";
	private static final String CONTACT_PHONE_NUMBER_NAME_YPOS = "CONTACT_PHONE_NUMBER_NAME_YPOS";

	private static final String SELECTED_IMAGE_NAME_AND_PATH = "SELECTED_IMAGE_NAME_AND_PATH";
	private static final String CREATED_IMAGE_NAME_AND_PATH = "CREATED_IMAGE_NAME_AND_PATH";

	
	public AppPreferences() {
		sharedPreferences = PreferenceManager.getDefaultSharedPreferences(BaseApplication.getInstance().getApplicationContext());
	}

	public static AppPreferences getInstance() {
		if (instance == null) {
			instance = new AppPreferences();
		}
		return instance;
	}

	public void setContactPhoneNumberXpos(float value) {
		sharedPreferences.edit().putFloat(CONTACT_PHONE_NUMBER_NAME_XPOS, value).commit();
	}

	public float getContactPhoneNumberXpos() {
		return sharedPreferences.getFloat(CONTACT_PHONE_NUMBER_NAME_XPOS, 0f);
	}

	public void setContactPhoneNumberYpos(float value) {
		sharedPreferences.edit().putFloat(CONTACT_PHONE_NUMBER_NAME_YPOS, value).commit();
	}

	public float getContactPhoneNumberYpos() {
		return sharedPreferences.getFloat(CONTACT_PHONE_NUMBER_NAME_YPOS, 100f);
	}

	public void setNewContactId(String value) {
		sharedPreferences.edit().putString(CONTACT_ID, value).commit();
	}

	public String getContactId() {
		return sharedPreferences.getString(CONTACT_ID, "");
	}

	public void setContactName(String value) {
		sharedPreferences.edit().putString(CONTACT_NAME, value).commit();
	}

	public String getContactName() {
		return sharedPreferences.getString(CONTACT_NAME, BaseApplication.getInstance().getResources().getString(R.string.not_selected_yet));
	}

	public void setNewContactPhoneNumber(String value) {
		sharedPreferences.edit().putString(CONTACT_PHONE_NUMBER, value).commit();
	}

	public String getContactPhoneNumber() {
		return sharedPreferences.getString(CONTACT_PHONE_NUMBER, BaseApplication.getInstance().getResources().getString(R.string.not_selected_yet));
	}

	public void setNewImageNameAndPath(String value) {
		sharedPreferences.edit().putString(SELECTED_IMAGE_NAME_AND_PATH, value).commit();
	}

	public String getImageNameAndPath() {
		return sharedPreferences.getString(SELECTED_IMAGE_NAME_AND_PATH, "");
	}
	
	public void setNewCreatedImageNameAndPath(String value) {
		sharedPreferences.edit().putString(CREATED_IMAGE_NAME_AND_PATH, value).commit();
	}

	public String getCreatedImageNameAndPath() {
		return sharedPreferences.getString(CREATED_IMAGE_NAME_AND_PATH, "");
	}

}
